﻿#ifndef FILAPOWERFORM_H
#define FILAPOWERFORM_H

#include <QWidget>
#include <QThread>
#include <QSettings>
#include <QIcon>
#include "link/ModBusTcpWorker.h"

namespace Ui {
class FilaPowerForm;
}

class FilaPowerForm : public QWidget
{
    Q_OBJECT
signals:
    void sig_SetProNameDevType(QString proName,int DevType);
    void sig_SetIPPort(QString address,short port);
    void sig_SetReadStartAddressAndRegisterCount(QList<int> startAddress, QList<int> registerCount,int RegisterType);
    //void sig_SetWriteStartAddressAndRegisterCount(int startAddress, int registerCount,QList<quint16> data);
    void sig_StartLoopReadRegister(bool start);

    void sig_AddWriteQueue(WriteData* data);   //增加写消息队列的数据

    void sig_showMessage(QString Msg);//状态栏显示的消息
public:
    explicit FilaPowerForm(QWidget *parent = nullptr);
    ~FilaPowerForm();

    void setWidgetFocus();

    void setIniFile(QSettings* settings);
protected :
    bool eventFilter(QObject *watched,QEvent *event) override;

public slots:
    void  slot_readBoolData(int MsgId,QList<bool> data);  //发送解析后bool数据
    void  slot_readfloatData(int MsgId,QList<float> data);  //发送解析后bool数据
    void slot_ConnectionState(bool isConnectionState);

    void slot_WriteDataQueueFinish();//写队列完成

private slots:
    void timeoutWatchDog_SingleTime();//单次定时器

    void on_btn_EleCurSet_clicked();

    void on_dSpinBox_EleCurSet_valueChanged(double arg1);

    void on_btn_Link_clicked();

    void on_btn_Fila_clicked();

    void on_btn_ReSet_clicked();

    void on_btn_SelfCtrl_clicked();

private:
    Ui::FilaPowerForm *ui;

    QThread* m_Thread;
    QTimer* m_SingleTime;

    ModBusTcpWorker* m_ModBusTcpWorker;

    bool bEleCurSetOnlyWrite;//电流设置读写区分标志
    bool bEleCurEditing;     //编辑中
    float m_fEleCurSet;

    QList<bool> m_BtnStatus;

    QIcon SwtichOffIcon;
    QIcon SwtichOnIcon;

    bool bConnectionState;


    QSettings* m_Settings;

};

#endif // FILAPOWERFORM_H
